package Arrays;

public class _485_MaxConsecutiveOnes {
    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0;
        int count = 0;
        int length = nums.length;
        for(int i=0;i<length;i++) {
            if (nums[i] == 1) {
                count++;
            } else {
                if (count > max) {
                    max = count;
                    count = 0;
                } else {
                    count = 0;
                }
            }
        }
        if (count > max) {
            max = count;
        }
        return max;
    }
}
